<?php

class twitterActions extends sfActions {

    public function executeIndex(sfWebRequest $request){
        $myLib = new myLib();

        /* valida que el usuario este conectado */
        $myLib->validateAuthentication("Twitter");

        $hybridauth = new Hybrid_Auth($myLib->getHybridAuthConfig());
        $twitter = $hybridauth->getAdapter("Twitter");

        // return TRUE or False <= generally will be used to check if the user is connected to twitter before getting user profile, posting stuffs, etc..
        //$is_user_logged_in = $twitter->isUserConnected();

        // uncomment the line below to get user friends list
        // $twitter->getUserContacts();

        // uncomment the line below to post something to twitter if you want to
        // $twitter->setUserStatus( "Hello world!" );

        // get the user profile
        $twitter_profile = $twitter->getUserProfile();


        // ex. on how to access the twitter api with hybridauth
        //     Returns the current count of friends, followers, updates (statuses) and favorites of the authenticating user.
        //     https://dev.twitter.com/docs/api/1/get/account/totals
        $account_totals = $twitter->api()->get('account/totals.json');

        // print recived stats
        //echo "Here some of yours stats on Twitter:<br /><pre>" . print_r( $account_totals, true ) . "</pre>";

        $this->account_totals = $account_totals;
    }

}